Skip to content

fix: Clean up attributes for traces and metrics#12677

Merged
blakeli0 merged 6 commits intomainfrom
fix-observability-tests
Apr 6, 2026
Merged

fix: Clean up attributes for traces and metrics#12677
blakeli0 merged 6 commits intomainfrom
fix-observability-tests

Conversation

@blakeli0
Copy link
Copy Markdown
Contributor

@blakeli0 blakeli0 commented Apr 3, 2026

This PR

  • Add exception.type and gcp.client.repo attributes to metrics.
  • Remove gcp.client.artifact and gcp.client.version from Span attributes since they are recorded as instrumentationName and instrumentationScope.
  • Refactor common logics of getting error attributes to ObservabilityUtils

@blakeli0 blakeli0 requested a review from a team as a code owner April 3, 2026 22:04
@blakeli0 blakeli0 changed the title fix: update observability attributes and tests fix: Clean up attributes for traces and metrics Apr 3, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors observability attribute collection by removing artifact and version attributes, centralizing error attribute logic into a new method, and updating tracing logic to use this centralized method. The review identified a consistent typo in the new method name 'gettErrorAttributes', which should be corrected to 'getErrorAttributes' across the codebase, including in the corresponding test method names.

@blakeli0 blakeli0 requested a review from lqiu96 April 3, 2026 22:21
@blakeli0 blakeli0 requested a review from lqiu96 April 4, 2026 04:27
ObservabilityUtils.populateStatusAttributes(attributes, null, transport);
metricsRecorder.recordOperationLatency(
clientRequestTimer.elapsed(TimeUnit.NANOSECONDS) / 1_000_000_000.0, attributes);
recordMetric(null);
Copy link
Copy Markdown
Member

@lqiu96 lqiu96 Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a blocker for this PR, but I feel that recordMetric(null) gives the wrong impression of the logic (maybe it's just to me and I may be just reading it too fast). At a first glance, I read the method like record no metric. Only after reading the signature did it make sense that the first param correspond to the error.

Maybe ideally something like recordErrorMetric that takes in the error param and recordMetric that records the status? But I guess that requires a bit of duplication in the logic.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I can definitely see the potential confusion. Let me give it more thoughts.

@blakeli0 blakeli0 merged commit 914f97f into main Apr 6, 2026
124 of 126 checks passed
@blakeli0 blakeli0 deleted the fix-observability-tests branch April 6, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants